using System.Collections.Generic;
using Microsoft.MediaCenter.Hosting;
using Microsoft.MediaCenter.UI;
using System;
using Playkanaler;
using System.Windows.Forms;

namespace Playkanaler
{

    public class Group : VirtualList //ModelItem
    {


        string title;
        int index;

        VirtualList items = new VirtualList();




        public VirtualList Items
        {
            get
            {
                return items;
            }
            set
            {
                items = value;
                FirePropertyChanged("Items");

            }
        }
        public string Title
        {
            get
            {
                return title;
            }
            set
            {
                title = value;
                FirePropertyChanged("Title");
            }
        }

        public int Index
        {
            get
            {
                return index;
            }
            set
            {
                index = value;
            }
        }

        public Group()
        {
            // Items.PropertyChanged+=new PropertyChangedEventHandler(Items_PropertyChanged);
        }
        public int QSearch(string str)
        {
            int i = 0;
            foreach (Item g in Items)
            {
                if (g.Title.ToLower().StartsWith(str.ToLower())) goto done;
                i++;
            }
            i = -1;
        done: ;
            return i;
        }
        public Group(string Title)
        {
            this.title = Title;

        }

        void Items_PropertyChanged(IPropertyObject sender, string property)
        {
            // MessageBox.Show(property);

            Count = Items.Count;
            //Items.PropertyChanged += new PropertyChangedEventHandler(Items_PropertyChanged);
        }
        public Group(string Title, VirtualList list)
        {
            this.title = Title;
            this.items = list;


        }


        //protected override void OnRequestItem(int index, ItemRequestCallback callback)
        //{
        //    //  MessageBox.Show(index.ToString());
        //    callback(this, index, Items[index]);
        //    //callback(this, index, new FilterItem("s","g","e"));
        //}






    }

}
